package com.example.zwlyz;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.zwlyz.ArticleListActivity;
import com.example.zwlyz.CartActivity;
import com.example.zwlyz.R;

import com.example.zwlyz.OrderListActivity;


public class ProfileFragment extends Fragment {

    private Button btnMyArticles;
    private Button btnMyOrders;
    private Button btnCart;
    private Button btnSetting;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_profile, container, false);

        btnMyArticles = view.findViewById(R.id.btnMyArticles);
        btnMyOrders = view.findViewById(R.id.btnMyOrders);
        btnCart = view.findViewById(R.id.btnCart);
        btnSetting=view.findViewById(R.id.btnSettings);
        btnMyArticles.setOnClickListener(v -> {
            // 跳转到我的文章页面
            startActivity(new Intent(getContext(), ArticleListActivity.class));
        });

        btnMyOrders.setOnClickListener(v -> {
            // 跳转到我的订单页面
            Intent intent = new Intent(getContext(), OrderListActivity.class);
            intent.putExtra("isOrderList", true); // 传递参数，表示是订单列表
            startActivity(intent);
        });

        btnCart.setOnClickListener(v -> {
            // 跳转到购物车页面
            startActivity(new Intent(getContext(), CartActivity.class));
        });
        btnSetting.setOnClickListener(v -> {
            // 跳转到设置页面
            startActivity(new Intent(getContext(), SettingsActivity.class));
        });
        return view;
    }
}